<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2021/3/22
 * Time: 10:21
 */

namespace api\modules\v2\controllers;

use Yii;
use api\controllers\OnAuthController;
use common\models\Author\Author;
use yii\debug\models\search\Db;

class AuthorController extends OnAuthController
{
    public $modelClass =Author ::class;

    protected $authOptional = ['index','recommend'];

    /**
     * @return string|\yii\data\ActiveDataProvider
     */
    public function actionRecommend()
    {
        $membercate = Author::find()->where(['recommend'=>1])->all();
        if($membercate){
            return $membercate;
        }else{
            return "请求失败";
        }
    }
    public function actionIndex()
    {
        $author = Yii::$app->request->get('member_cate_id');
        $membercate = Author::find()->where(['member_cate_id'=>$author])->all();
        if(empty($membercate)){
            return "请输入作者分类id";
        }else{
            if ($membercate){
                return $membercate;
            }else{
                return "请求失败";
            }
        }
    }
}